import dbConf from '@/conf/dbConfig'
import { Sequelize } from 'sequelize'

// sequelize 连接数据库
function initSeq() {
  const { database, host, password, port, user } = dbConf
  return new Sequelize(database, user, password, {
    host,
    port,
    dialect: 'mysql',
    timezone: '+08:00',
    define: {
      timestamps: false,
      freezeTableName: true,
    },
    pool: {
      max: 5, //连接池最大的连接数
      min: 0, //最小的连接数量
      idle: 10000, //如果一个连接 10 s之内没使用，则释放
    },
  })
}
const sequelize = initSeq()
export default sequelize
